/*
 * @Author: White
 * @description: 路由配置
 * @LastEditTime: 2021-07-07 19:28:26
 */

import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

/**
 * 重写路由的push方法
 */
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

const routes = [
  {path:'/',redirect:'/InfoMation'},
  {
      path: '/ShopGoods',
      name: 'ShopGoods',
      component: () => import('@/page/ShopGoods/ShopGoods.vue'),
      meta: { title: '商品详情页' }
  },
  {
      path: '/InfoMation',
      name: 'InfoMation',
      component: () => import('@/page/InfoMation/InfoMation.vue'),
      meta: { title: '资讯详情页' }
  },
]

const router = new VueRouter({
  // mode: 'history',  //除非后端支持，否则开启打包失败
  routes,
  // 处理路由调整新页面指定位置
  scrollBehavior() {
    return { x: 0, y: 0 }
  }
})

router.beforeEach((to, from, next) => {
  //路由发生改变时,触发
  window.document.title = "潮牌客"
  next();
})
  
export default router